local hx__wanjian = fk.CreateSkill {

  name = "hx__wanjian",

  tags = { Skill.Compulsory, },

}



hx__wanjian:addEffect("active", {
  name = "hx__wanjian",
  anim_type = "offensive",
  prompt = "#hx__wanjian_prompt",
  can_use = function (self, player)
    return player:getMark("@hx__jianqi") > 0 and player:usedSkillTimes(hx__wanjian.name) < 3
  end,
  interaction = function (self, player)
    local num = player:getMark("@hx__jianqi")
    return UI.Spin{from = 1 ,to = num }
  end,
  card_num = 0,
  card_filter = Util.FalseFunc,
  min_target_num = 1,
  target_filter = function (self, player, to_select, selected, selected_cards)
    return self.interaction.data > 0
  end,
  on_use = function (self, room, effect)
    local player = effect.from
    room:removePlayerMark(player,"@hx__jianqi",self.interaction.data)
    local choices = {"hx__wanjian_fire","hx__wanjian_thunder"}
    local damagetype = fk.FireDamage
    local choice = room:askToChoice(player,{ choices = choices, skill_name = hx__wanjian.name})
    if choice == "hx__wanjian_fire" then
      damagetype = fk.FireDamage
    else
      damagetype = fk.ThunderDamage
    end
    for _, to in ipairs(effect.tos) do
      if to.shield > 0 then
        room:changeShield(to,-to.shield)
      end
      room:damage{
        to = to,
        damage = self.interaction.data,
        damageType = damagetype,
        from = player,
        skillName = hx__wanjian.name,
      }
    end
    room:loseHp(player,2,hx__wanjian.name)
  end,
})

return hx__wanjian